package main

import (
	"fmt"
	"time"
)

func main() {

	ch1 := make(chan int, 10)
	ch2 := make(chan int, 10)

	go func() {
		for {
			ch1 <- 1
			time.Sleep(1 * time.Second)
		}
	}()

	go func() {
		for {
			ch2 <- 1
			time.Sleep(500 * time.Millisecond)
		}
	}()

	for {
		select {
		case <-ch1:
			fmt.Println("从ch1收到数据")
			go time.Sleep(2 * time.Second)
		case <-ch2:
			fmt.Println("从ch2收到数据")
			go time.Sleep(2 * time.Second)
		}
	}

}
